
import * as sync_pb from "./pb/sync_pb";

import { create } from "@bufbuild/protobuf";
import { EzGameReqInstance } from "./base/EzGameReqInstance";
import { ApiMetaData } from "./base/ApiMetaData";
import { EzGameUtils } from "./base/EzGameUtils";

/**
 * 自动生成的代码
 * id=1
 * desc:装备系统
 * version:0
 */
export class SyncApi {

    private static readonly enterMap_1_1: number = ApiMetaData.registerReqMeta(65537, "穿戴装备");
    private static readonly move_1_2: number = ApiMetaData.registerReqMeta(131075, "卸下装备");

        /**
     * method_id=1
     * full_id=10001
     * version:0
     * desc=穿戴装备
     * @returns 
     */
    public static enterMap():EzGameReqInstance<sync_pb.EnterMapReq,sync_pb.PlayerData>{
        // 对象池中获取
        let req = create(sync_pb.EnterMapReqSchema); 
        let instance =  EzGameReqInstance.create<sync_pb.EnterMapReq,sync_pb.PlayerData>(req)
        //设置请求id
        instance.cmd  = this.enterMap_1_1
        instance.netName = "default" //指定网络连接名称
        //设置请求值的编码器
        instance.reqDataEncoder = (data)=>{
            return EzGameUtils.objDataEncode(sync_pb.EnterMapReqSchema,data)
        }

        //设置返回值的解析结构
        instance.respDataDecoder = (data)=>{
            return EzGameUtils.objDataDecode(sync_pb.PlayerDataSchema,data) as sync_pb.PlayerData
        }
        return instance
    }
            /**
     * method_id=1
     * full_id=10001
     * version:0
     * desc=穿戴装备
     * @returns 
     */
    public static move():EzGameReqInstance<sync_pb.MoveReq,sync_pb.MoveResp>{
        // 对象池中获取
        let req = create(sync_pb.MoveReqSchema); 
        let instance =  EzGameReqInstance.create<sync_pb.MoveReq,sync_pb.MoveResp>(req)
        //设置请求id
        instance.cmd  = this.enterMap_1_1
        instance.netName = "default" //指定网络连接名称
        //设置请求值的编码器
        instance.reqDataEncoder = (data)=>{
            return EzGameUtils.objDataEncode(sync_pb.MoveReqSchema,data)
        }

        //设置返回值的解析结构
        instance.respDataDecoder = (data)=>{
            return EzGameUtils.objDataDecode(sync_pb.MoveRespSchema,data) as sync_pb.MoveResp
        }
        return instance
    }
}